package world2d;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.Serializable;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import utils.World;

public class Agent2d extends JFrame implements Serializable {

	private static final long serialVersionUID = 1L;
	
	private World _world;
	private static final int POSITION_DIM = 25;
	private static final int DIVIDE_DIM = 2;
	private int _gameWidth;
	private int _gameHeight;

	public Agent2d(World world, int NUMBER_OF_PLAYERS)
	{
		_world = world;
		_gameWidth = (_world.getXmax()+1)*(POSITION_DIM)+DIVIDE_DIM;
		_gameHeight = (_world.getYmax()+1)*(POSITION_DIM)+DIVIDE_DIM;
		int possibleWidth = 150 * NUMBER_OF_PLAYERS;
		
		int finalGameWidth;
		int finalGameHeight;
		
		if(_gameWidth<possibleWidth) finalGameWidth = possibleWidth;
		else finalGameWidth = _gameWidth;
		
		finalGameHeight = _gameHeight + 300*2;
		
		//add(new World2d(_world, _gameWidth, _gameHeight));
		/*JPanel container = new JPanel();
		container.add();*/
		JPanel toShow = new World2d(_world, _gameWidth, _gameHeight);
		JScrollPane jsp = new JScrollPane(toShow);
		toShow.setPreferredSize(new Dimension(finalGameWidth, finalGameHeight));
		toShow.setAutoscrolls(true);
		getContentPane().add(jsp, BorderLayout.CENTER);
		
		setTitle("AlienWorld");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setSize(800, 600);
		setLocationRelativeTo(null);
		setVisible(true);
	}

}
